{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c34bbc82",
   "metadata": {},
   "source": [
    "# 上周回顾："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bce7c4f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# start/ stop/ step"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c5a603dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8f00acc7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# for + range决定了循环的次数\n",
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e286a1ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 5)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1e34f1ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for i in range(1,11,2):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19c6be5d",
   "metadata": {},
   "source": [
    "# 本周内容："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "98f09e3d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ca96217b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9 <class 'int'>\n"
     ]
    }
   ],
   "source": [
    "## 整形\n",
    "##int\n",
    "\n",
    "a = 9\n",
    "print(a,type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "fec93036",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "11.1 <class 'float'>\n"
     ]
    }
   ],
   "source": [
    "## 浮点形\n",
    "## float\n",
    "\n",
    "b = 11.1\n",
    "print(b,type(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e10c53e4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(6+2j) <class 'complex'>\n"
     ]
    }
   ],
   "source": [
    "## （复数/虚数）\n",
    "## camplex\n",
    "\n",
    "c = 6 + 2j\n",
    "print(c,type(c))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e6bb2d17",
   "metadata": {},
   "source": [
    "# 2.字符串(string):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "2e9fa0f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hjqug\"mxah'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 斜杠 \\ 作为转义符号\n",
    "\"hjqug\\\"mxah\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "37f2b1f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'\\nelkjwvlcw./j;feuwkc/saic;k;jec;jw;jc;ejclw;lcj;clshxsiha\\n'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 三引号 \"\"\"neirong\"\"\" 里面可以容纳任何符号\n",
    "\n",
    "\"\"\"\n",
    "elkjwvlcw./j;feuwkc/saic;k;jec;jw;jc;ejclw;lcj;clshxsiha\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ad14df49",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院坐落于广州市从化区温泉镇\n"
     ]
    }
   ],
   "source": [
    "title=\"广州南方学院坐落于广州市从化区温泉镇\"\n",
    "print(title)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6591f936",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "81a6d597",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'南'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 取单一值\n",
    "title[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "0c4bd6f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "## 取多个值\n",
    "title[:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5bd16c18",
   "metadata": {},
   "outputs": [],
   "source": [
    "## enumerate 枚举，既可以获取 内容，又可以获取到 索引值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e6b85d8b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 广\n",
      "1 州\n",
      "2 南\n",
      "3 方\n",
      "4 学\n",
      "5 院\n",
      "6 坐\n",
      "7 落\n",
      "8 于\n",
      "9 广\n",
      "10 州\n",
      "11 市\n",
      "12 从\n",
      "13 化\n",
      "14 区\n",
      "15 温\n",
      "16 泉\n",
      "17 镇\n"
     ]
    }
   ],
   "source": [
    "## 利用for进行循环\n",
    "for a,b in enumerate(title):\n",
    "    print(a,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "0e0d27b2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州这俩字在里面\n"
     ]
    }
   ],
   "source": [
    "## in 检查是否在其中\n",
    "if \"广州\" in title:\n",
    "    print(\"广州这俩字在里面\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b5d2866",
   "metadata": {},
   "source": [
    "### 字符串拼接"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "f23d11eb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你好IU\n"
     ]
    }
   ],
   "source": [
    "print(\"你好\"+\"IU\")\n",
    "## 字符串不能与数值进行连接"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "8517a0ca",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "can't multiply sequence by non-int of type 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [28]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m## 字符串不可以进行运算\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m2\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m3\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n",
      "\u001b[1;31mTypeError\u001b[0m: can't multiply sequence by non-int of type 'str'"
     ]
    }
   ],
   "source": [
    "## 字符串不可以进行运算\n",
    "\"2\"*\"3\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb699601",
   "metadata": {},
   "source": [
    "* 字符串的方法:\n",
    ">1.capitalize(): 可以将首字母大写\n",
    ">2.count(): 出现的次数\n",
    ">3.split(): 拆分"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6c2f0739",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title.count(\"广州\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "9ccd9394",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['广州南方学院坐落', '广州市从化区温泉镇']"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "title.split(\"于\")\n",
    "## 可以搜索 停止词 字典，进行文本分析，然后进一步做分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c1702dd2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
